package com.qf.shop.car.shop14car;

import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.WeightedResponseTimeRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestBody;

@SpringBootApplication(scanBasePackages = "com.qf.shop", exclude = DataSourceAutoConfiguration.class)
@EnableEurekaClient
@EnableFeignClients(basePackages = "com.qf.shop.car.feign")
public class Shop14CarApplication {

    private String name;

    public static void main(String[] args) {
        SpringApplication.run(Shop14CarApplication.class, args);
    }


    // 设置ribbon负载均衡的策略为随机的
    @Bean
    public IRule RandomRule() {
//        return new RandomRule();
        return new WeightedResponseTimeRule();
    }
}
